package com.lxw.study.behavioral.responsibilitychain.unionspring;

import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class HandlerChain {
    @Resource
    private List<IHandler> handlers;

    public void handler(String name, boolean isReturn) {
        for (IHandler handler : handlers) {
            if (handler.support(name)) {
                handler.handle();
                if (isReturn) {
                    return;
                }
            }
        }
    }

}

